﻿function SmartSpace() {
    this._callbackFunc = null;
    this.popup = function (url) {

        $("#ss_popup_mask").css("display", "block");
        $("#ss_popup").css("display", "block");
        $("#ss_popup_frame").attr("src", url);

       this. _callbackFunc = null;
    }

    this.popup = function (url, callbackFunc) {

        $("#ss_popup_mask").css("display", "block");
        $("#ss_popup").css("display", "block");
        $("#ss_popup_frame").attr("src", url);

        this._callbackFunc = callbackFunc
    }

    this.close = function (data) {
        $("#ss_popup_mask").css("display", "none");
        $("#ss_popup").css("display", "none");
        if (this._callbackFunc != null) {
            this._callbackFunc(data);
        }
    }

    this.hide = function () {
        $("#ss_popup_mask").css("display", "none");
        $("#ss_popup").css("display", "none");
    }

    this.dlg = function (url) {
        var result = window.showModalDialog(url, '', '');
        return result;
    }

    this.picker = function (url, ctlDisplay, ctlValue) {
        var result = window.showModalDialog(url, '', 'dialogHeight:500px;dialogWidth:300px');
        if (result != null || result != undefined) {
            $('#' + ctlDisplay).val(result.text);
            $('#' + ctlValue).val(result.value);
        }
        return result;
    }
}

var _ss = new SmartSpace();


$(function () {
    $("#ss_popup").css("display", "none");
    $("#ss_popup_busy").css("display", "none");

    //$(document.getElementById('ss_popup_frame').contentWindow).unload(function () {
    //    window.parent.document.getElementById("ss_popup_busy").style.display = "block";
    //});

    //$("#ss_popup_frame").load(function () {
    //    $("#ss_popup_busy").css("display", "none");
    //    $(document.getElementById('ss_popup_frame').contentWindow).unload(function () {
    //        window.parent.document.getElementById("ss_popup_busy").style.display = "block";
    //    });
    //});
});